<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">

    <title>后台</title>

    <link href="__PUBLIC__/images/favicon.ico" rel="shortcut icon" />

    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="__PUBLIC__/css/bootstrap.min.css" />
    <link rel="stylesheet" href="__PUBLIC__/css/bootstrap-theme.min.css" />
    <link rel="stylesheet" href="__PUBLIC__/css/dashboard.css" />
    <link rel="stylesheet" href="__PUBLIC__/css/icheck/all.css" />
</head>

<body>

<include file="Common/topNav" />
<div class="container-fluid">
    <div class="row">
        <include file="Common/leftMenu" />
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <div class="cont-title clearfix">
                <div class="title">入驻团队</div>
                <div class="btn-group">
                    <button class="btn" type="button" id="addTeam">添加</button>
                </div>
            </div>
            <include file="searchTeam" />
            <div class="table-responsive">
                <table class="table table-striped table-hover" id="tableData">
                    <thead>
                    <tr>
                        <th>团队名称</th>
                        <th>公司名称</th>
                        <th>所属空间</th>
                        <th>人数</th>
                        <th>入驻时间</th>
                        <th>离开时间</th>
                        <th>入驻状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                   
                    <volist name="data['list']" id="dl">
                        <tr>
                            <td>{$dl.team_name}</td>
                            <td>{$dl.company.name}</td>
                            <td>{$dl.space.name}</td>
                            <td>{$dl.team_number}</td>
                            <td><if condition="$dl['enter_time']">{$dl.enter_time|date="Y-m-d",###}</if></td>
                            <td><if condition="$dl['leave_time']">{$dl.leave_time|date="Y-m-d",###}</if></td>
                            <td>
                                <if condition="$dl['status'] eq 1">
                                    <span class="label label-success">当前入驻</span>
                                <elseif condition="$dl['status'] eq 0"/>
                                    <span class="label label-primary">历史入驻</span>
                                <elseif condition="$dl['status'] eq 4"/>
                                    <span class="label label-warning">待入驻</span>
                                <else/>
                                    -
                                </if>
                            </td>
                            <td>
                                <a href="{:U('Admin/Space/Settled/teamDetail',array('teamId'=>$dl['id']))}" class="edit">查看</a>
                                | <a href="{:U('Admin/Space/Settled/teamUser',array('teamId'=>$dl['id']))}" class="">人员管理</a>
                                <if condition="$dl['status'] eq 1">
                                    | <a href="javascript:void(0);" thisId="{$dl['id']}" class="history">移入历史入驻</a>
                                </if>
                                | <a href="javascript:void(0);" thisId="{$dl['id']}" class="delete">删除</a>
                            </td>
                        </tr>
                    </volist>
                    </tbody>
                </table>
                <div class="page">
                    {$data.page}
                </div>
            </div>
        </div>
    </div>
</div>

<include file="Common/modalHtmls" />
<script type="text/javascript" src="__PUBLIC__/js/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/bootstrap.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/icheck.min.js"></script>

<script>

    $("#addTeam").click(function () {
        common.htmlAjax("{:U('Admin/Space/Settled/addTeam')}", {}, function (html) {
            if(common.isJsonString(html)){
                var error = JSON.parse(html);
                if (error.info){
                    common.alert("提示",error.info);
                }
                return;
            }
            $("#commonModal").html(html).modal({show: true, backdrop: 'static', keyboard: false});
        })
    })
    
    $("#tableData .history").click(function(){
        var teamId = $(this).attr("thisId");
        common.confirm("提示", "确定要移入历史入驻?", function () {
            common.ajax("{:U('Admin/Space/Settled/inHistory')}", {teamId : teamId}, function (data) {
                //console.log(data);
                if (data == true) {
                    common.alert("提示", "移入历史入驻成功!", function () {
                        common.reload();
                    });
                } else if (data.info){
                    common.alert("提示",data.info);
                }

            });
        });
    })
    
    $("#tableData .delete").click(function(){
        var teamId = $(this).attr("thisId");
        common.confirm("提示", "确定要删除入驻团队?", function () {
            common.ajax("{:U('Admin/Space/Settled/deleteTeam')}", {teamId : teamId}, function (data) {
                //console.log(data);
                if (data == true) {
                    common.alert("提示", "删除入驻团队成功!", function () {
                        common.reload();
                    });
                } else if (data.info){
                    common.alert("提示",data.info);
                }
            });
        });
    })
    
</script>
</body>
</html>
